<div class="panel panel-default">
	<div class="panel-heading">
		<?php 
		$this->widget('zii.widgets.CBreadcrumbs',array(
				'links'=>array(
						'后台管理',
						'文章列表'
		)
		));
		?>
	</div>
	<div class="panel-body">
		<p class="text-right">
			<a href="<?php echo $this->createUrl('article/add');?>" class="btn btn-primary">添加文章</a>
		</p>
		<table class="table table-hover">
			<thead>
				<tr>
					<th>文章ID号</th>
					<th>文章栏目</th>
					<th>标题</th>
					<th>发布时间</th>
					<th>文章状态</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
			<?php foreach($list as $v):?>
				<tr>
					<td><?php echo $v['article_id'];?></td>
					<td><?php echo $v['category'];?></td>
					<td><?php echo $v['title'];?>
						<?php 
							if(count($v['attr'] > 0)){
								foreach($v['attr'] as $attrV){
									echo '<label class="label label-primary">'.$attrV['attr_name'] . '</label>&nbsp;&nbsp;';
								}
							}
							
						?>
					</td>
					<td><?php echo date('Y-m-d',$v['post_time']);?></td>
					<td>正常</td>
					<td>
						<a href="<?php echo $this->createUrl('edit', array('aid'=>$v['article_id']));?>">编辑</a>
						<a href="<?php echo $this->createUrl('delete'); ?>" class="delete" aid="<?php echo $v['article_id'];?>">删除</a>
					</td>
				</tr>
			<?php endforeach;?>
			</tbody>
		</table>
	</div>
	<div class="panel-footer">
	<nav>
	<?php
		//分页widget代码: 
		$this->widget('CLinkPager',array('pages'=>$pages));
	?>
		</nav>
	</div>
</div>
<script>
	$(function(){
		$('.delete').click(function(){
			var c = confirm("确定要删除吗？");
			if(!c){
				return false;
				}
			
			$this = $(this);
			$.ajax({
				method : 'POST',
				url : $(this).attr('href'),
				data : {'aid' : $(this).attr('aid')},
				success : function(data){
					data = eval('('+data+')');
					if(data.code == 1){
							$this.parents('tr').remove();
						} else {
							alert('删除失败');
							}
					}
				});
			return false;
			});
		});
</script>